package com.swa99ylum.pxp.a.a000;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;


public class Eoo2 {
	private String aaa;
	
	private List<?> ttt;
	private Class<?> clazz;

	/**
	 * List<T> ttt, Class<T> clazz
	 * ttt 和 clazz 所 使用的 泛型，必须一样
	 */
	public <T> Eoo2(String aaa, List<T> ttt, Class<T> clazz) throws InstantiationException, IllegalAccessException {
		super();
		this.aaa = aaa;
		
		this.ttt = ttt;
		this.clazz = clazz;
		
//		qwe = bbb;
//		
//		Object zxc = qwe.get(0);
//		System.out.println(zxc);
//		qwe.add(ele);
		
//		ccc.add(new Object());
//		System.out.println(qwe);
	}
	

	public void eoo() throws InstantiationException, IllegalAccessException, InvocationTargetException {
		Object ele = clazz.newInstance();
		
		BeanUtils.setProperty(ele, "name", "李四123");
		BeanUtils.setProperty(ele, "id", "666");
		
		Object ele2 = clazz.newInstance();
		
		BeanUtils.setProperty(ele2, "name", "zxc李四123");
		BeanUtils.setProperty(ele2, "id", "zxc666");
		
		
		
		//1========================================
		/**
		 * List<?> 不能 进行 修改 操作
		 */
		//ttt.add(e);
		
		//2========================================
		@SuppressWarnings("unchecked")
		List<Object> aaa =  (List<Object>) ttt;
		aaa.add(ele);
		aaa.add(ele2);
		
	}
	

	
	public static void main(String[] args) throws InstantiationException, IllegalAccessException, InvocationTargetException {
		
		List<Student> sss = new ArrayList<Student>();
		Eoo3<Student> eoo = new Eoo3<Student>("aaa", sss, Student.class);
		
		List<Car> ccc = new ArrayList<Car>();
		Eoo3<Car> eoo1 = new Eoo3<Car>("aaa", ccc, Car.class);
		
		
		eoo.eoo();
		eoo1.eoo();
		
		/**
		 * java 不支持 泛型数组
		 */
//		Eoo<Object>[] eoos = new Eoo[]{eoo, eoo1};
		
		for (Student student : sss) {
			System.out.println(student);
		}
		
		
		
	}
	
	
	
	
	
}
